package com.bdqn.zhao.controller;


import com.bdqn.zhao.pojo.IpFloor;
import com.bdqn.zhao.service.IpFloorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * <p>
 * 楼层表 前端控制器
 * </p>
 *
 * @author zhangsan
 * @since 2023-04-24
 */
@Controller
@RequestMapping("/ipFloor")
public class IpFloorController {

    @Autowired
    private IpFloorService ipFloorService;


    // 楼层列表 新增楼层
    @ResponseBody
    @PostMapping("/ipFloorsave")
    public Boolean ipFloorsave(IpFloor ipFloor,HttpSession session) {
        return ipFloorService.ipFloorsave(ipFloor,session);
    }

    // 楼层列表 -- 修改楼层信息
    @ResponseBody
    @PostMapping("/update/{floorId}")
    public Boolean updates(@PathVariable int floorId,IpFloor ipFloor, HttpSession session) {
        return ipFloorService.updates(floorId, ipFloor, session);
    }

    //楼层列表 -- 删除楼层信息
    @ResponseBody
    @GetMapping("/delete/{floorId}")
    public Boolean deletefloor(@PathVariable int floorId) {
        return ipFloorService.deletefloor(floorId);
    }

    // 跳转 -------------------------------------------
    // 楼层列表 跳转楼层列表 并查询出对应楼层信息 带分页 --上下页分页
    @ResponseBody
    @GetMapping("/selectAll/{buildId}/{index}/{count}")
    public String selectAll(@PathVariable int buildId,
                            @PathVariable int index,
                            @PathVariable int count, HttpSession session) {
        return ipFloorService.selectAll(buildId,index,count,session);
    }


    // 楼层列表 删除楼层信息 转发全查楼层信息方法 重新刷新页面
    @GetMapping("/plush")
    public String plush() {
        return "forward:/ipFloor/selectAll/{buildId}/{index}/{count}";
    }

}

